"""
    Canny边缘检测
        cv.Canny(image, threshold1, threshold2)
            参数：image：灰度图，threshold1：minval，较小的阈值将间断的边缘连接起来，threshold2：maxval，较大的阈值检测图像中明显的边缘
"""
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt

# 1. 读取图像
img = cv.imread("image/horse.jpg", 0)

# 2. 边缘检测
lowThreshold = 0
max_lowThreshold = 100
canny = cv.Canny(img, lowThreshold, max_lowThreshold)

# 3. 图像显示
plt.figure(figsize=(10, 8), dpi=100)
plt.subplot(121), plt.imshow(img, cmap=plt.cm.gray), plt.title("原图")
plt.xticks([]), plt.yticks([])
plt.subplot(122), plt.imshow(canny, cmap=plt.cm.gray), plt.title("Canny检测后结果")
plt.xticks([]), plt.yticks([])
plt.show()

